<!-- src/layouts/AdminLayout.vue -->
<template>
  <div class="admin-layout">
    <AdminHeader v-if="showHeader" />
    <div class="main-wrapper">
      <AdminNavbar v-if="showNav" />
      <div class="content-wrapper">
        <router-view />
      </div>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue' // 新增的导入
import { useRoute } from 'vue-router'
import AdminHeader from '@/components/AdminHeader.vue'
import AdminNavbar from '@/components/AdminNavbar.vue'

const route = useRoute()
const showHeader = computed(() => route.meta.requiresAuth)
const showNav = computed(() => route.meta.requiresAuth)
</script>

<style scoped>
.admin-layout {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f5f7f9;
}

.main-wrapper {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.content-wrapper {
  flex: 1;
  padding: 24px;
  overflow: auto;
  background: #fff;
  margin: 16px;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}
</style>